//
//  TileList.h
//  MapEdit
//
//  Created by Steven Canfield on 16/06/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <OpenGL/gl.h>
#import "ColorPalette.h"
#import "TilePieceList.h"
#import "DebugLog.h"

#pragma options align=packed
struct tile_t {
	u_int16_t micro_tiles[16];
};
typedef struct tile_t tile_t;

typedef struct _vec3 {
	u_int8_t r;
	u_int8_t g;
	u_int8_t b;
} vec3;

typedef struct _tileInfo {
	float	s;
	float	t;
	GLuint  texID;
} tileInfo;

@interface TileList : NSObject {
	tile_t			**	_tiles;
	int					_tileCount;

	NSMutableArray	*	_tilesBitmap;
	ColorPalette	*	_palette;
	TilePieceList	*	_pieceList;
	
	NSMutableArray	*	_colorIDList;
	GLuint			*	_textureID;
	int					_textureCount;
	
	tileInfo		*	_tileInfo;
}

- (id)initWithData:(NSData *)data pieceList:(TilePieceList *)pieces palette:(ColorPalette *)palette;
- (tile_t)tileAtIndex:(int)index;
- (void)createTexture;
- (NSColor *)minimapColorForTileAtIndex:(int)index;
- (NSImage *)bitmapForTileAtIndex:(int)index;
- (TilePieceList *)pieceList;

- (int)textureAtIndex:(int)index;
- (int)textureCount;

- (float)textureS:(int)tileId;
- (float)textureT:(int)tileId;
- (GLuint)textureID:(int)tileId;
@end
